home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 407 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: gate.net!pslfl2-23
  2. From: bhutto@gate.net (William Hutto)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: extern and static are they compatable
  5. Date: 5 Jan 1996 02:44:40 GMT
  6. Organization: CyberGate, Inc.
  7. Message-ID: <4ci3ao$f84@news.gate.net>
  8. References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
  9. NNTP-Posting-Host: pslfl2-44.gate.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <ahicksDKM8Ap.FBp@netcom.com>,
  13.    ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
  14. >Folks,
  15. >
  16. >  I'm working on a project which requires use to create large array 
  17. >( approximately 500 K bytes ) so we decided to make it static so it would  
  18. >not have be created each time the routines that use it are called.  We then
  19. >found out that we needed a nother program to acess this array so in the 
  20. second
  21. >file we defined this array as a extern.  Now each time we compile and link 
  22. >the programs we get an error stating that the array is undefined.  The error
  23. >is displayed while linking.  After reading all I could find about extern 
  24. >I can not find any thing that says this is correct behavior.  I then changed 
  25. >the static decloration to a non static and the thing compiles with out a 
  26. >problem.  Now I'm wandering if any of the great mind on the net could 
  27. >enlighten me as to why the static declaration would cause this error.  
  28.  
  29. <snip>
  30.  
  31. If you explicitely use the _static_ keyword you limit an object's scope to 
  32. _file_. This holds true for functions as well:
  33.  
  34. static void func(void)
  35. {
  36. }
  37.  
  38. can only be called from within it's own file. This can be a somewhat effective 
  39. means of code and data hiding in C.
  40.  
  41. Bill
  42.  
  43. "Whatcha got on?...Your mind?"
  44.